<?php session_start();
validaAcesso(); 

echo "<h2>".$_SESSION["menu"]["rel"][20]." ".$_SESSION["NOME_HOSTEL_"]."</h2>";

?>
 <script type="text/javascript" src="css2/calendar/dhtmlgoodies_calendar.js"></script>
            <form method='POST' action='index.jsp?rel=20&cont=1' autocomplete='off'>
            
              <b>Data Inicial:</b>
              <input type="text" value="<?php echo date("d/m/Y"); ?>" readonly name="pdatai"  id="pdatai" id="pdatai">
              <img src="images/data.gif" border="0" style="cursor:hand;" onclick="displayCalendar(document.getElementById('pdatai'),'dd/mm/yyyy',this);">

              &nbsp;<b>Data Final:</b>
              <input type="text" value="<?php echo date("d/m/Y"); ?>" readonly name="pdataf"  id="pdataf" id="pdataf">
              <img src="images/data.gif" border="0" style="cursor:hand;" onclick="displayCalendar(document.getElementById('pdataf'),'dd/mm/yyyy',this);">


          <input type='submit' value='Gerar Estat&iacute;stica'>
			<div align='right'><a href="javascript:void(0);" onclick="getLink('rel',7,false);"><img src='images/seta_voltar.gif' border='0'> voltar para Listagem de Relat&oacute;rios</a></div>
        </form>
        
        

<?php
if($_GET["cont"]==1){ 


	$novo_datai=formataData($_POST["pdatai"], true);
	$novo_dataf=formataData($_POST["pdataf"], true);

        

		$sql="	select 
					itm.ds_item, 
					alm.dt_entrada, 
					alm.vl_entrada
				from 
					hostel_almoxarifado alm,
					hostel_item itm
				where
					(itm.id_hostel_item = alm.id_hostel_item) AND
					(alm.dt_entrada between   '$novo_datai' and '$novo_dataf')
            ";
            
		
	$linha=$_SESSION['ADOCnn']->Execute("$sql");
	
	$periodo = "Per&iacute;odo: ".formataData($novo_datai)." At&eacute; ".formataData($novo_dataf);
	echo "<h2>$periodo</h2>";
	
	   echo "<table class='perfil $class'>
   	                                             
                    <table class='perfil'>
                    <tr class='titulo'>
                    	<td width=100>Produto</td>  
                    	<td width=110>Data de Entrada</td>
                      	<td width=100 align='center'>Valor do Produto</td>                      	               
                    </tr>                    
                    ";
         
                     $class="odd";       

    $n=0; 
 
    $valor=0;
    
	if($linha->RecordCount()!=0){
	while(!$linha->EOF){                     
                  
                  if($class == "odd"){$class="even";}else{$class="odd";}     

                  $preco= number_format($linha->fields['vl_entrada'],'2',',',',');
                  
                  
                  
                  $valor=$valor+$preco;                 
                 
                 echo"
                  <tr class='$class'>
                      <td>".formataData($linha->fields['dt_entrada'])."</td>
                      <td>{$linha->fields['ds_item']}</td>
                      <td align='center'>R$ $preco</td>                                            

                   </tr>
                   
                ";
                $n++;
 				$linha->MoveNext();
 				
 				
				}                                         
             
		$res_valor = number_format($valor,'2',',',',');
		
             echo"</table><b>Resultados:</b> <u>$n</u><br>";
             echo"<b>Total no Estoque:</b> <u>R$ $res_valor</u><br>";
	}
}

        
?>
